package org.advanced.base;

import java.util.concurrent.*;

/**
 * @author John.zhang
 * @version Id: Cabled, v 1.0 2020/12/7 14:12 ZhiYong Exp $
 * 可以让线程得到一个返回值
 */
public class Cabled implements Callable<String> {


    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return "call";
    }

    public static void main(String[] args) throws Exception {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        Future<String> future = executorService.submit(new Cabled());
        //阻塞
        System.out.println(Thread.currentThread().getName() + "-" + future.get());
    }
}
